using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Crimson;
using Crimson.Module;

public partial class Controls_NewsList : UserControl
{
    public string InfoTypeId
    {
        get { return ViewState["InfoTypeId"].ToString(); }
        set { ViewState["InfoTypeId"] = value; }
    }

    /// <summary>
    /// 
    /// </summary>
    public int ListNumber
    {
        get
        {
            if (ViewState["ListNumber"] == null)
                return 10;
            return (int) ViewState["ListNumber"];
        }
        set { ViewState["ListNumber"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public void DataBind(string infoTypeName,bool cascade)
    {
        bulleteList.DataSource = InfoManager.DaoFactory.InfoDao.Find(infoTypeName, 0, ListNumber, cascade,
                                                                     InfoState.Published);
        bulleteList.DataBind();
    }

    public void DataBind(string infoTypeName)
    {
        DataBind(infoTypeName, false);
    }


    protected void CreateUrl(object sender, EventArgs e)
    {
        foreach (ListItem s in bulleteList.Items)
        {
            s.Value = ResolveUrl("~/Crimson/?Id=") + s.Value;
        }
    }
}